﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoreSimple
{
    class ImageHelperSimple
    {
        public void Test()
        {
            using (Stream stream = DotNetExtensions.Core.Image.Converter.Compress(@"C:\Users\Administrator\Downloads\R-C.jpg"))
            {
                using (FileStream fileStream = new FileStream(@"C:\Users\Administrator\Downloads\R-C-50.jpg", FileMode.Create, FileAccess.Write))
                {
                    byte[] buffer = new byte[1024];
                    int len = 0;
                    stream.Position = 0;
                    while ((len = stream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fileStream.Write(buffer, 0, len);
                    }

                    fileStream.Flush();
                }
            }


            using (Stream stream = DotNetExtensions.Core.Image.Converter.Compress(@"C:\Users\Administrator\Downloads\R-C.jpg", 30, 0.3f))
            {
                using (FileStream fileStream = new FileStream(@"C:\Users\Administrator\Downloads\R-C-30.jpg", FileMode.Create, FileAccess.Write))
                {
                    byte[] buffer = new byte[1024];
                    int len = 0;
                    stream.Position = 0;
                    while ((len = stream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fileStream.Write(buffer, 0, len);
                    }

                    fileStream.Flush();
                }
            }

            using (Stream stream = DotNetExtensions.Core.Image.Converter.Compress(@"C:\Users\Administrator\Downloads\R-C.jpg", 50, 0.1f))
            {
                using (FileStream fileStream = new FileStream(@"C:\Users\Administrator\Downloads\R-C-10.jpg", FileMode.Create, FileAccess.Write))
                {
                    byte[] buffer = new byte[1024];
                    int len = 0;
                    stream.Position = 0;
                    while ((len = stream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fileStream.Write(buffer, 0, len);
                    }

                    fileStream.Flush();
                }
            }
        }
    }
}
